<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>jQuery+jqueryfrom上传附件</title>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script src="//cdn.bootcss.com/jquery.form/3.51/jquery.form.min.js"></script>
</head>
<body>
<input id="fileupload" type="file" name="mypic" value="上传附件">
<script type="text/javascript">
$(function () {
	$("#fileupload").wrap("<form id='myupload' action='action.php' method='post' enctype='multipart/form-data'></form>");
    $("#fileupload").change(function(){
		$("#myupload").ajaxSubmit({
			dataType:  'json',
			success: function(data) {
				var img = data.pic;
				console.log(img);
			},
			error:function(xhr){
				console.log("error");
			}
		});
	});
});
</script>
</body>
</html>